<?php
/************************************************************************/
/* FrameWork  test preview                                              */
/* ==================================================================== */
/*                                                                      */
/* This program is free software. You can redistribute it and/or modify */
/* it under the terms of the GNU General Public License as published by */
/* the Free Software Foundation; either version 2 of the License.       */
/************************************************************************/

$find=$_POST['find'];
$find=str_replace("*","",$find);
if ($find=="")$find="*";
print("<form enctype='multipart/form-data' action='index.php?appname=$appname&action=search' method='post'>
	<input type='text' name='find' value='$find' size='40' />
	<input type='submit' value='Search' /></form>\n");

if ($hdir=opendir("datas/applications/".apptitle($appname)."/pages")) {
    while(($hfile=readdir($hdir))!=false){
	if ($hfile[0]!="."){
	    if (substr_count($hfile,$find)>0 || $find=="*"){
		print ("<a href='index.php?appname=$appname&page=$hfile'>$hfile</a><br/>");
	    }
	    else{
		$tmp= file("datas/applications/".apptitle($appname)."/pages/".$hfile);
		foreach($tmp as $ln){
		    if (substr_count($ln,$find)>0){
			print ("<a href='index.php?appname=$appname&page=$hfile'>$hfile</a><br/>");
		    }
		}
	    }
	}
    }
}
closedir($hdir);
?>
